package com.CmJava.tomcat.Server.service.container;

import com.CmJava.tomcat.Server.Component;
import com.CmJava.tomcat.Server.life.Lifecycle;
import com.CmJava.tomcat.Server.life.LifecycleState;

public class Wrapper implements Lifecycle, Component {

    private LifecycleState lifecycleState=LifecycleState.NEW;
    private Component child;


    public Wrapper(Component child) {
        this.child = child;
    }

    public Component getChild() {
        return child;
    }

    public void setChild(Component child) {
        this.child = child;
    }

    @Override
    public void init() {
        child = new HttpServlet();
        lifecycleState=LifecycleState.INITIALIZED;
    }

    @Override
    public void start() {
        if (child==null){
            child = new HttpServlet();
            lifecycleState=LifecycleState.INITIALIZED;
        }
        HttpServlet httpServlet = (HttpServlet) child;
        httpServlet.start();
    }

    @Override
    public void stop() {

    }

    @Override
    public void destroy() {

    }

    @Override
    public LifecycleState getState() {
        return null;
    }
}
